package core.hxl.controller;

import core.hxl.dynamicdatasource.TargetDataSource;
import core.hxl.service.UserSevice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("db")
public class DbController {

    @Autowired
    private UserSevice userSevice;

    @GetMapping("user")
    public String getUserInfo(){
        return userSevice.getUserMessage();
    }

    @TargetDataSource("test")
    @GetMapping("user/test")
    public String getUserInfoTest(){
        return userSevice.getUserMessage();
    }

    @TargetDataSource("bugfree")
    @GetMapping("user/bugfree")
    public String getUserInfoBugfree(){
        return userSevice.getUserMessage();
    }

}
